﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace com.sharepointutils.application
{
    public partial class ExceptionForm : Form
    {


        public ExceptionForm(object exception)
        {
            InitializeComponent();
            Exception ex = exception as Exception;
            if (ex != null)
            {
                LoadException(ex); 
            }
            
        }

        private void LoadException(Exception ex)
        {
            StringBuilder message = new StringBuilder();
            message.Append("Message: " + Environment.NewLine + ex.Message + Environment.NewLine );
            message.Append("Stack Trace: " + Environment.NewLine + ex.StackTrace);
            if (ex.InnerException != null)
            {
                message.Append(Environment.NewLine + Environment.NewLine + "Inner Exception:" + Environment.NewLine);
                message.Append("Message: " + Environment.NewLine + ex.InnerException.Message + Environment.NewLine);
                message.Append("Stack Trace: " + Environment.NewLine + ex.InnerException.StackTrace);
            }
            textBox_exceptionText.Text = message.ToString();
        }

        private void button_ok_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
